package logger

import "fmt"

var (
	fileLogger    Logger
	consoleLogger Logger
)

// Logger
type Logger interface {
	Debug(format string, v ...interface{})
	Info(format string, v ...interface{})
	Warn(format string, v ...interface{})
	Error(format string, v ...interface{})
}

func InitLogger(level, logType, logFilePath string) error {
	consoleLogger = nil
	fileLogger = nil

	if logType == ConsoleLog {
		consoleLogger = NewConsoleLogger(level)
	} else if logType == FileLog {
		fileLogger = NewFileLogger(logFilePath, level)
	} else {
		return fmt.Errorf("Log type is not valid\n")
	}

	return nil
}

func GetLogger() Logger {
	if fileLogger != nil {
		return fileLogger
	}

	if consoleLogger != nil {
		return consoleLogger
	}

	return nil
}
